' Ball shader ' BASIC Anywhere Machine program ' by ZXDunny 2023 sw=800 sh=480 screen _newimage(sw,sh,24) ' SpecBAS uses this as its default window size xc=sw/2 yc=sh/2 r=100 amb=0.0125 k=3 mxp=(1-amb)*255 r2=r*r do lx=xc-_mousex ly=yc-_mousey lz=-75 cls l=sqr(lx*lx+ly*ly+lz*lz) nlx=lx/l nly=ly/l nlz=lz/l for x=-r to r x2=x*x for y=-r to r y2=y*y if x2+y2<=r2 then v2=sqr(r2-x2-y2) l=sqr(x2+y2+v2*v2) v0=x/l v1=y/l v2=v2/l d=nlx*v0+nly*v1+nlz*v2 i=mxp*(iff(d<0,-d^k,0)+amb) ink=_RGB32(int(i),int(i),int(i)) plot(x+xc,y+yc),ink end if next y next x _display loop